#pragma once

#include "../common/singleton.h"
#include "radar.h"
#include <vector>
#include <memory>
#include <mutex>
#include "../TmsMap/TmsMapTool.h"

class MainMap;

class RadarManager
{
public:
    DECLARE_SINGLETON_CLASS(RadarManager);

    RadarManager();
    ~RadarManager();

    void ClearAllRadars();
    void AddRadar(std::shared_ptr<Radar> radar);

    void DrawAllRadars(QPainter & painter, unsigned int map_key, double &range_meters, size_t &spoke_len);
    void DrawAllRadarsBDisplay(QPainter & painter, QSize &window_size, double &range_meters, size_t &spoke_len);
    void SetMainMap(MainMap *map, int index) { m_main_map[index] = map; }

    void SetWindowSize(const QSize &size, int index) { m_window_size[index] = size; }
    void SetModifyTrackers(bool modify_trackers);

    void AddManualTrackers(double lon, double lat, int map_key = 0);
    void SetBDisplay(bool val);
    void SetSave2File(bool save);
    void ClearTrails();
    void SetTrailLevel(unsigned int level);
    void SetRadarLocation(double lon, double lat, double alt);
    void SetRadarAutoTracker(bool auto_tracker);

    double GetFirstRadarLongitude();
    double GetFirstRadarLatitude();
    double GetFirstRadarAltitude();

    double GetFirstRadarSecPerCycle();
private:
    MainMap *m_main_map[MAP_COUNT];

    std::vector<std::shared_ptr<Radar> > m_all_radars;

    QSize m_window_size[MAP_COUNT];

    std::atomic_bool m_is_b_display;
};

typedef pattern::singleton<RadarManager >  sln_radar_manager;
